import request from '@/utils/request'
const moduleApi = '/operation'

// 活动优惠券列表
export function getCouponListApi(params) {
  return request({
    url: moduleApi + `/marCoupon`,
    method: 'get',
    params
  })
}
// 已启用的点位列表
export function getPositionListApi(params) {
  return request({
    url: 'tissue' + `/position/list`,
    method: 'get',
    params
  })
}
// 套餐列表
export function getComboListApi(params) {
  return request({
    url: 'goods' + `/combo/list`,
    method: 'get',
    params
  })
}
// 新增活动
export function addActivityApi(data) {
  return request({
    url: moduleApi + `/marCoupon/add`,
    method: 'post',
    data
  })
}
// 删除/失效活动 0删除 2失效
export function deleteActivityApi(params) {
  return request({
    url: moduleApi + `/marCoupon`,
    method: 'delete',
    params
  })
}
// 数据详情
export function getStatisticApi(params) {
  return request({
    url: moduleApi + `/marCoupon/data`,
    method: 'get',
    params
  })
}
// 已领取优惠券列表
export function getClaimedCouponApi(params) {
  return request({
    url: moduleApi + `/marCoupon/acquire`,
    method: 'get',
    params
  })
}
// 发放优惠券
export function distributeCouponApi(data) {
  return request({
    url: moduleApi + `/marCoupon/grant`,
    method: 'post',
    data
  })
}
// 获取优惠券详情
export function getCouponDetailApi(params) {
  return request({
    url: moduleApi + `/marCoupon/id`,
    method: 'get',
    params
  })
}
// 获取优惠券口令
export function getCouponLinkApi(params) {
  console.log('params', params)
  return request({
    url: moduleApi + `/marCoupon/generateShortLink`,
    method: 'get',
    params
  })
}
// 延长时间
export function extendCouponApi(data) {
  return request({
    url: moduleApi + `/marCoupon/lengthen`,
    method: 'post',
    data
  })
}
// 导出单个优惠券延长时间
export function extendExportCouponApi(data) {
  return request({
    url: moduleApi + `/marCoupon/exportLengthen`,
    method: 'post',
    data
  })
}
// 已领取单个优惠券延长时间
export function extendReceiveCouponApi(data) {
  return request({
    url: moduleApi + `/client/coupon/lengthen`,
    method: 'post',
    data
  })
}
// 校验是否有弹窗
export function checkPopupApi(params) {
  console.log('params', params)
  return request({
    url: moduleApi + `/miniBanner/check`,
    method: 'get',
    params
  })
}
// 导出详情
export function exportDetailApi(params) {
  return request({
    url: moduleApi + `/marCoupon/derivedetail`,
    method: 'get',
    params
  })
}
// 导出详情失效
export function expireCouponApi(params) {
  return request({
    url: moduleApi + `/marCoupon/invalid`,
    method: 'put',
    params
  })
}
// 已领取失效
export function expireGetCouponApi(params) {
  return request({
    url: moduleApi + `/marCoupon/inviteinvalid`,
    method: 'put',
    params
  })
}

// 模板校验
export function checkTemplateApi(data) {
  return request({
    url: moduleApi + `/marCoupon/templateVerify`,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

// 定向添加
export function directionalAddApi(data) {
  return request({
    url: moduleApi + `/marCoupon/directionalAdd`,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}
// 定向发放列表
export function getDirectionalListApi(params) {
  return request({
    url: moduleApi + `/marCoupon/directionalList`,
    method: 'get',
    params
  })
}
// 定向批量发放
export function directionalGrantApi(data) {
  return request({
    url: moduleApi + `/marCoupon/grantOrienteering`,
    method: 'post',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
}
// 删除定向发券列表
export function deleteDirectionalApi(data) {
  return request({
    url: moduleApi + `/marCoupon/deleteById`,
    method: 'delete',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
}

/**一键删除 */
export function deletAllApi(couponId) {
  return request({
    url: moduleApi + `/marCoupon/directional/bulk/del?couponId=${couponId}`,
    method: 'delete'
  })
}
